<template>
  <div id="page4">
    <p>23430104 董宇轩 我的</p>
    <span>账号：</span
    ><el-input
      v-model="username"
      placeholder="请输入账号"
      style="width: 60%"
    ></el-input
    ><br />
    <span>密码：</span
    ><el-input
      placeholder="请输入密码"
      v-model="password"
      show-password
      style="width: 60%; margin-top: 10px"
    ></el-input>
    <el-button
      type="primary"
      style="margin-top: 10px; margin-left: 60%"
      @click="login"
      >登录</el-button
    >
  </div>
</template>

<script>
import {userlogin} from "../api/data";
export default {
  name: "page4",
  data() {
    return {
      username: "",
      password: "",
    };
  },
  methods: {
    login() {
      console.log("账号：", this.username);
      console.log("密码：", this.password);
      userlogin({ username: this.username, password: this.password }).then(
        (res) => {
          console.log("接口返回", res);
          if (res.data == "登录成功") {
            this.$router.push("/page1");
          } else {
            this.$message.error("输入的账号或密码错误");
          }
        }
      );
    },
  },
};
</script>

<style>
</style>
